capture log close
log using replica_tab2_coll_rev_6.log,replace

*       REPLICA_TAB2_COLL_REV_6.LOG

*       FIRST VERSION   NOVEMBER 2, 2009
*       THIS VERSION    AUGUST 10, 2012

*       LAST REVISOR    AI

*       INPUT FILE:             BASE12_6.DTA
*       OUTPUT FILE:            ANALISYS FOR REVISION AT RESTAT
*
*	REPLICATION FILE  FOR TABLE 2 AND COLLATERAL EFFECTS


version 9.0

di "log file printed on $S_DATE at $S_TIME"


set more 1
clear
program drop _all
macro drop _all
scalar drop _all

# delimit ;

set scheme s1color;
set memory 300000; 
set matsize 250;
tempfile tmpf1 tmpf2 tmpf3 tmpf4;

use base12_6, clear;

xtdes;

* KEEP MEDIA PRIMO ANNO;
sort id anac;
qui by id: gen gpa_1 = gpa[1]; 

* lagged income and taxes;
gen ym1 = l1.y;
gen ydm1 = l1.yd;
gen tteom1 = l1.tteo;
gen tpaidm1 = l1.tpaid;

gen ym2 = l2.y;
gen ydm2 = l2.yd;
gen tteom2 = l2.tteo;
gen tpaidm2 = l2.tpaid;

gen ym3 = l3.y;
gen ydm3 = l3.yd;
gen tteom3 = l3.tteo;
gen tpaidm3 = l3.tpaid;


********************
* PREDIZIONE QUARTO ANNO FUORI CORSO DELLE TASSE;

xtdes;

tab anac, gen(daa);
gen y2 = y*y;
gen y3 = y*y2;
gen y4 = y*y3;

reg f1.tpaid tpaid  y y2 y3 y4 daa*, robust;

reg f1.tteo tteo  y y2 y3 y4 daa*, robust;


* SELEZIONE DEL CAMPIONE;
* keep studenti in corso regolare al 4 anno;
keep if real_status==4&aniscr==4&posizione==14 ;

xtdes;

*******NEW
* restrizione della distanza dalla soglia;
keep if yd>-3&yd<3;

xtdes;





* VARIABILI NECESSARIE;





label var y "Real income - thousands of Euros, base 2000";

tab fascia_teo, gen(dfa);

gen yd2 = yd*yd;
gen yd3 = yd2*yd;
gen yd4 = yd3*yd;

label var yd "Distance from nearest discontinuity in 1000 euros";


* ALTRE VARIABILI NECESSARIE PER ANALISI  RDD;


*generate for compliance analysis;
gen comp = tpaid>=tteo1;
label var comp "fraction with tpaid >tteo1";

* generate dummies for nearest discontinuity;
tab neardisc , gen(dnear);

* calcola gli scarti dalla media di anno/punto di discontinuit�

sort anac neardisc;
egen mtp=mean(tpaid), by(anac neardisc);
gen wtp=tpaid-mtp;
label var wtp "paid tuition in deviation from mean";



* VARIABILI PRE INTERVENTION;

* Normalizzazione del voto di matematica;
gen normat = (mat - 0)/(31-0);
sum normat votodip;
corr normat votodip;

* Normalizzazione del voto di statistica;
gen norsta = (sta - 0)/(31-0);
sum norsta votodip;
corr norsta votodip;

* Normalizzazione del gpa 1 anno;
gen norgpa1 = (gpa_1 - 0)/(31-0);
sum norgpa1 votodip;
corr norgpa1 votodip;

* generate dummy liceo from  tipo diploma;
gen typedip =  cod_tit_dipl ==1 ;


* altre variabili da usare nelle regressioni

outmil
female
votodip

;



# delimit cr



*
*****************************
*****************************
*****************************
* ANALISI PER REVISIONE

*

***************************
label var tteo "Official tuition"
label var female "Female"
label var outmil "Family of origin  outside Milan"
label var votodip "Highschool grade"
label var typedip "Highschool type"
label var ym3 "Income before Bocconi"

sum tteo female outmil votodip typedip ym3




recode neardisc ( 1 2 3 = 1) (4 5 6 7 = 2) (8 9 10 = 3), gen(near3)
tab neardisc near3



***********************************
**********************************  MAIN RESULTS
**********************************


****************
*REGRESSIONE BASE ITT

reg tpaid tteo y y2 y3 y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo    using tab2, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) replace  tex label/*
*/ ct(TP)

reg fc tteo y y2 y3 y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo    using tab2, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append  tex label/*
*/ ct(FC)

*****************
*REGRESSIONE BASE CON CONTROLLI ESOGENI

reg tpaid tteo y y2 y3 y4  daa* female outmil votodip typedip ym3 , robust 
local r2=e(r2_a)
outreg2   tteo  female outmil votodip typedip ym3  using tab2, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append tex label/*
*/ ct(TP)


reg fc tteo y y2 y3 y4  daa* female outmil votodip typedip ym3 , robust 
local r2=e(r2_a)
outreg2   tteo  female outmil votodip typedip ym3  using tab2, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append  tex label/*
*/ ct(FC)


****************
* ANALISI CON POLINOMI SEPARATI PER GRUPPI DI DISCONTINUITA' E CON CONTROLLI ESOGENI

xi: reg tpaid tteo female outmil votodip typedip ym3 i.near3*y i.near3*y2 i.near3*y3 i.near3*y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo  female outmil votodip typedip ym3  using tab2, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append tex label/*
*/ ct(TP)

xi: reg fc tteo female outmil votodip typedip ym3 i.near3*y i.near3*y2 i.near3*y3 i.near3*y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo  female outmil votodip typedip ym3  using tab2, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append tex label/*
*/ ct(FC)



***********************************
**********************************  COLLATERAL EFFECTS
**********************************

****************
*REGRESSIONE BASE ITT

reg dropout tteo y y2 y3 y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo    using colres1, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) replace  tex label/*
*/ ct(drop)

reg votolau tteo y y2 y3 y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo    using colres1, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append  tex label/*
*/ ct(voto)

*****************
*REGRESSIONE BASE CON CONTROLLI ESOGENI

reg dropout tteo y y2 y3 y4  daa* female outmil votodip typedip ym3 , robust 
local r2=e(r2_a)
outreg2   tteo  using colres1, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append tex label/*
*/ ct(drop)


reg votolau tteo y y2 y3 y4  daa* female outmil votodip typedip ym3 , robust 
local r2=e(r2_a)
outreg2   tteo  using colres1, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append  tex label/*
*/ ct(voto)


****************
* ANALISI CON POLINOMI SEPARATI PER GRUPPI DI DISCONTINUITA' E CON CONTROLLI ESOGENI

xi: reg dropout tteo female outmil votodip typedip ym3 i.near3*y i.near3*y2 i.near3*y3 i.near3*y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo  using colres1, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append tex label/*
*/ ct(drop)

xi: reg votolau  tteo female outmil votodip typedip ym3 i.near3*y i.near3*y2 i.near3*y3 i.near3*y4  daa*, robust 
local r2=e(r2_a)
outreg2   tteo  using colres1, nor noaster addstat(R2, (`r2')) /*
*/  bdec(3) append tex label/*
*/ ct(voto)








log close






